<!doctype html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
	<meta charset="UTF-8">
	<title>后台登录-Long-admin</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link  th:href="@{/X-admin/css/font.css}" rel="stylesheet" type="text/css">
    <link  th:href="@{/X-admin/css/xadmin.css}" rel="stylesheet" type="text/css">


</head>
<body class="login-bg">
    
    <div class="login">
        <div class="message">后台管理系统登录</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" >
            <input name="name" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="pwd" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
    </div>
    <!-- 底部结束 -->
    <script type="text/javascript"  th:attr="src=@{/X-admin/lib/jquery-3.2.1.min.js}"></script>
    <script type="text/javascript"  th:attr="src=@{/X-admin/lib/layui/layui.js}"></script>
    <script type="text/javascript"  th:attr="src=@{/X-admin/js/xadmin.js}"></script>
</body>
</html>

<script>
    $(function  () {
        layui.use('form', function(){
            var form = layui.form;
            // layer.msg('玩命卖萌中', function(){
            //   //关闭后的操作
            //   });
            //监听提交
//            layer.alert(JSON.stringify(data.field), {
//                title: '最终的提交信息'
//            });

            form.on('submit(login)', function(data){

                console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
                console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
                console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
                $.ajax({
                    type: 'POST',
                    url: "/ajaxLogin",
                    data: data.field,
                    success: function (result) {
                        if (result.success){
//                            layer.msg(result.msg,function(){
//                                location.href='/main.html'
//                            });
//                            jQuery.post({
//                                url:'/mainController/main'
//                            });
//                            location.href='/mainController/main'
                        }else{
                            layer.msg(result.msg,function(){

                            });
                        }
                    },
                    dataType: "json"
                });
//                layer.msg(JSON.stringify(data.field),function(){
//                    location.href='main.html'
//                });
                return false;
            });
        });
    })


</script>